/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package com.elcom.emocbc.cbcdb.dao;

import com.elcom.emocbc.cbcdb.tables.BscInfo;
import com.elcom.emocbc.cbcdb.tables.records.BscInfoRecord;
import com.elcom.util.DBUtil;
import java.sql.Connection;
import java.sql.SQLException;
import java.util.List;
import org.jooq.DSLContext;
import org.jooq.SQLDialect;
import org.jooq.impl.DSL;

/**
 *
 * @author GiangLT
 */
public class BscInfoDao extends BaseDao<BscInfo> {

    private BscInfo BSC_INFO = BscInfo.BSC_INFO;

    public List<BscInfoRecord> getAllBscs() throws SQLException {
        Connection con = DBUtil.getConnection(JNDI);

        try {
            DSLContext context = DSL.using(con, SQLDialect.MYSQL);
            return context.selectFrom(BSC_INFO).fetch();
        } finally {
            DbAccess.closeConnection(con);
        }

    }
    
    public BscInfoRecord findById(String bscId) throws SQLException {
        Connection con = DBUtil.getConnection(JNDI);

        try {
            DSLContext context = DSL.using(con, SQLDialect.MYSQL);
            return context.selectFrom(BSC_INFO).where(BSC_INFO.BSC_ID.eq(bscId)).fetchOne();
        } finally {
            DbAccess.closeConnection(con);
        }

    }

    @Override
    protected String getInsertSql(BscInfo record, DSLContext context) throws SQLException {
        throw new UnsupportedOperationException("Not supported yet."); //To change body of generated methods, choose Tools | Templates.
    }
}
